package com.carambatv.android.ui.sliding;

import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;

import com.actionbarsherlock.view.MenuItem;
import com.carambatv.android.R;
import com.google.android.apps.analytics.GoogleAnalyticsTracker;
import com.slidingmenu.lib.SlidingMenu;

public class ResultActivity extends BaseActivity {
	private GoogleAnalyticsTracker tracker;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		tracker = GoogleAnalyticsTracker.getInstance();
		tracker.startNewSession("UA-29688793-1", this);

		SlidingMenu sm = getSlidingMenu();
		setSlidingActionBarEnabled(true);
		sm.setBehindScrollScale(0.99f);

		if (savedInstanceState == null) {
			Fragment mFragment = new GridFragment();
			FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
			transaction.add(R.id.grid_fragment, mFragment);
			transaction.commit();
		}

	}

	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
	}

	@Override
	protected void onResume() {
		super.onResume();

		GoogleAnalyticsTracker.getInstance().trackPageView(getClass().getSimpleName());

		getSupportActionBar().setHomeButtonEnabled(true);
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		tracker.dispatch();
		tracker.stopSession();
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			toggle();
			return true;

		}
		return super.onOptionsItemSelected(item);
	}

}
